'use strict';

# examples
# https://github.com/angular-ui/bootstrap/blob/master/src/buttons/test/buttons.spec.js
# https://github.com/angular-ui/bootstrap/blob/master/src/alert/test/alert.spec.js

describe 'common directive', ()->

  beforeEach(module('UCX.Cmis'))
  $scope={}
  $compile={}
  $rootScope={}
  $timeout = {};
  beforeEach((inject (_$compile_, _$rootScope_,_$timeout_)->
    $compile = _$compile_
    $rootScope = _$rootScope_
    $timeout = _$timeout_
  ))
  it 'qrcode generate qr', inject ($controller)->
    element = $compile("<div data-url='www.baidu.com' qrcode></div>")($rootScope);
    $rootScope.$digest()
    $timeout.flush()
    expect(element.html()).toEqual('<canvas width="50" height="50"></canvas>')

  it 'autoSelect input ', inject ($controller)->

#    element.click()
#    http://stackoverflow.com/questions/17211466/how-can-i-simulate-a-click-event-in-my-angularjs-directive-test
#    element = angular.element("<input value='www.baidu.com' auto-select-all>")
#    compiled = $compile(element)($rootScope)
    element = $compile("<input value='www.baidu.com' auto-select-all>")($rootScope);
    $rootScope.$digest()
    if element.click
      element.click()
    else
      element.triggerHandler('click')


    $timeout.flush()
    expect($rootScope.select_succ).toEqual(true)
